import { _decorator, Component, Label, Node, Slider, Sprite, Toggle, Vec2, Vec3 } from 'cc';
import { UIManager } from '../UIManager';
import { LanauageManager } from '../LanauageManager';
import { GameData, shopCfg, shopData } from '../GameData';
import { HttpClient } from '../net/HttpClient';
import { EventManager } from '../EventManager';
import { AudioMgr } from '../AudioMgr';
import { Util } from '../Util';
const { ccclass, property } = _decorator;

@ccclass('shopItem')
export class shopItem extends Component {

    @property(Node)
    unLock:Node = null;

    @property(Node)
    lock:Node = null;

    @property(Sprite)
    icon:Sprite = null;

    @property(Label)
    nameLab:Label = null;

    @property(Label)
    rewardLab:Label = null;

    shopData:shopData;

    shopCfg:shopCfg;

    onEnable() {

    }

    refresh(shopData:shopData){
        this.lock.active = false;
        this.unLock.active = false;
        if (!shopData){
            this.lock.active = true;
            return;
        }
        this.unLock.active = true;
        this.shopData = shopData;

        this.shopCfg = GameData.getItemDataByIdAndCfgs(this.shopData.lv, GameData.shopCfgs);
        if (!this.shopCfg){
            return;
        }

        Util.loadSprite("imag/shop/" + this.shopData.lv, this.icon);

        this.nameLab.string = this.shopCfg.name;
    }

    onClickHandler(event:Event, str:string){

    }
}

